#include <algorithm>

#include "../include/DirectoryScanner.h" 

using std::vector;
using std::string;
using std::cout;
using std::endl;
using std::sort;

vector<string> DirectoryScanner::scan(const string &dir)
{
    DIR *dir_p = opendir(dir.c_str());
    
    vector<string> fileNameList;
    
    while(dirent *dirent_p = readdir(dir_p))
    {
        if(dirent_p->d_type == DT_REG){
            fileNameList.push_back(dir + "/" + dirent_p->d_name);   
        }
    }
    
    sort(fileNameList.begin(), fileNameList.end());
    closedir(dir_p);
    return fileNameList;
}